package org.example.admin.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.common.utils.ResponseUtil;
import org.example.db.entity.Goods;
import org.example.db.mapper.GoodsMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminGoodsListService {
    GoodsMapper goodsMapper;

    public AdminGoodsListService(GoodsMapper goodsMapper) {
        this.goodsMapper = goodsMapper;
    }

    public List<Goods> getGoodsList(){
        return goodsMapper.selectList(null);
    }

    public void deleteGoods(Long id){
        goodsMapper.deleteById(id);

    }

    public int CountTotal(){
        return goodsMapper.selectCount(null);
    }

    public IPage<Goods> getPageGoods(Page<Goods> page){
        return goodsMapper.selectPage(page,null);
    }

    public Goods getGood(Long id){
        return goodsMapper.selectById(id);
    }
}
